package ctl.example.HtmlParseDemo;

import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import org.htmlcleaner.HtmlCleaner;
import org.htmlcleaner.TagNode;
import android.util.Log;

public class htmlReader {
    TagNode rootNode;
    
    public htmlReader(URL htmlPage) throws IOException
    {
        HtmlCleaner cleaner = new HtmlCleaner();
        rootNode = cleaner.clean(htmlPage);
    }

    public List<TagNode> getLinksByClass()
    {
        List<TagNode> linkList = new ArrayList<TagNode>();// lay ra mot danh sach cac TagNode
        TagNode linkElements[] = rootNode.getElementsByName("p", true);
        for (int i = 0; linkElements != null && i < linkElements.length; i++)
        {        
            String classType = linkElements[i].getAttributeByName("style");
            if (classType != null && classType.contains("text-align: justify"))
            {
            	linkList.add(linkElements[i]);
            }
        }
        return linkList;
    }
}
